package com.jqsoft.launcher.activity.bean;

import com.jqsoft.launcher.util.Log;

import org.json.JSONArray;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户登录的缓存信息
 * 
 * @author iven
 * 
 */
public class UserLoginInfo {
	private final String tag = this.getClass().getName();// "UserLoginInfo";
	private static UserLoginInfo userinfo;
	// 是否登录
	private boolean loginStatus = false;
	
	// 对于每一个域名设置一个cookie
	private static Map<String, List<JQCookie>> cookies;

	// 是否登录成功
	private boolean isLoginFailure = false;

	// ------------------版本更新，客户端版本检查信息---------------------
	private String updateStatus = "";
	private String updateMessage = "";
	private String updateUrl = "";
	private boolean showedUpdateMessage;

	private String sLoginName = "";// 登录名
	private String sAlias = "";// 登录名别名
	private String sUserName = "";// 用户姓名
	private String sOrganizationKey = "";// 机构主键【用户所在机构，下同】
	private String sOrgInstitutionCode = "";// 组织机构代码
	private String sOrganizationName = "";// 机构名称
	private String sOrganizationTypeCode = "";// 机构类型编码
	private String sOrganizationLevelCode = "";// 机构级别编码
	private String sManagementDivisionCode = "";// 管理区划编码
	private String sManagementDivisionName = "";// 管理区划名称
	private String sAndroidReader ="";//读取身份证参数 1支持  0


	private  JSONArray jsonArrayDoctors ;//医生姓名信息

	private String apkVersion;// 客户端版本号

	public static UserLoginInfo getInstances() {
		if (null == userinfo) {
			userinfo = new UserLoginInfo();
		}
		return userinfo;
	}

	private UserLoginInfo() {
		cookies = new HashMap<String, List<JQCookie>>();
	}

	public boolean isLoginStatus() {
		return loginStatus;
	}

	public void setLoginStatus(boolean loginStatus) {
		this.loginStatus = loginStatus;
	}

	public boolean isLoginFailure() {
		return isLoginFailure;
	}

	public void setLoginFailure(boolean isLoginFailure) {
		this.isLoginFailure = isLoginFailure;
	}

	public void clean() {
		loginStatus = false;
		isLoginFailure = true;
		userinfo = null;
		cookies = null;
	}

	public String getUpdateStatus() {
		return updateStatus;
	}

	public void setUpdateStatus(String updateStatus) {
		this.updateStatus = updateStatus;
	}

	public String getUpdateMessage() {
		return updateMessage;
	}

	public void setUpdateMessage(String updateMessage) {
		this.updateMessage = updateMessage;
	}

	public String getUpdateUrl() {
		return updateUrl;
	}

	public void setUpdateUrl(String updateUrl) {
		this.updateUrl = updateUrl;
	}

	public Map<String, List<JQCookie>> getCookies() {
		return cookies;
	}

	public void setCookies(Map<String, List<JQCookie>> cookies) {
		Log.e(tag, "UserLoginInfo 设置的cookies 为空。");
		if (null != cookies) {
			UserLoginInfo.cookies = cookies;
		}
	}

	public void clearCookie(String domainName) {
		Log.e(tag, "清空这个域的cookie:" + domainName);
		if (null != cookies) {
			cookies.put(domainName, null);
		}
	}

	public void clearCookies() {
		if (null != UserLoginInfo.cookies) {
			UserLoginInfo.cookies.clear();
		}
	}

	public boolean isShowedUpdateMessage() {
		return showedUpdateMessage;
	}

	public void setShowedUpdateMessage(boolean showedUpdateMessage) {
		this.showedUpdateMessage = showedUpdateMessage;
	}

	public String getApkVersion() {
		return apkVersion;
	}

	public void setApkVersion(String apkVersion) {
		this.apkVersion = apkVersion;
	}

	public String getsLoginName() {
		return sLoginName;
	}

	public void setsLoginName(String sLoginName) {
		this.sLoginName = sLoginName;
	}

	public String getsAlias() {
		return sAlias;
	}

	public void setsAlias(String sAlias) {
		this.sAlias = sAlias;
	}

	public String getsUserName() {
		return sUserName;
	}

	public void setsUserName(String sUserName) {
		this.sUserName = sUserName;
	}

	public String getsOrganizationKey() {
		return sOrganizationKey;
	}

	public void setsOrganizationKey(String sOrganizationKey) {
		this.sOrganizationKey = sOrganizationKey;
	}

	public String getsOrgInstitutionCode() {
		return sOrgInstitutionCode;
	}

	public void setsOrgInstitutionCode(String sOrgInstitutionCode) {
		this.sOrgInstitutionCode = sOrgInstitutionCode;
	}

	public String getsOrganizationName() {
		return sOrganizationName;
	}

	public void setsOrganizationName(String sOrganizationName) {
		this.sOrganizationName = sOrganizationName;
	}

	public String getsOrganizationTypeCode() {
		return sOrganizationTypeCode;
	}

	public void setsOrganizationTypeCode(String sOrganizationTypeCode) {
		this.sOrganizationTypeCode = sOrganizationTypeCode;
	}

	public String getsOrganizationLevelCode() {
		return sOrganizationLevelCode;
	}

	public void setsOrganizationLevelCode(String sOrganizationLevelCode) {
		this.sOrganizationLevelCode = sOrganizationLevelCode;
	}

	public String getsManagementDivisionCode() {
		return sManagementDivisionCode;
	}

	public void setsManagementDivisionCode(String sManagementDivisionCode) {
		this.sManagementDivisionCode = sManagementDivisionCode;
	}

	public String getsManagementDivisionName() {
		return sManagementDivisionName;
	}

	public void setsManagementDivisionName(String sManagementDivisionName) {
		this.sManagementDivisionName = sManagementDivisionName;
	}

	public JSONArray getJsonArrayDoctors() {
		return jsonArrayDoctors;
	}

	public void setJsonArrayDoctors(JSONArray jsonArrayDoctors) {
		this.jsonArrayDoctors = jsonArrayDoctors;
	}
	public String getsAndroidReader() {
		return sAndroidReader;
	}

	public void setsAndroidReader(String sAndroidReader) {
		this.sAndroidReader = sAndroidReader;
	}

}
